package com.javasm.sys.tree;

import com.javasm.aftersales.RepairType;
import com.javasm.sys.SysPos;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


public class PosTreeUtil {
    public  static List<SysPos> buildTree(Collection<SysPos> list,String pid){
        List<SysPos> r=new ArrayList<>();
        for(SysPos sysPos:list){
            if(pid.equals(sysPos.getPid())){
                String id = sysPos.getPosId();
                List<SysPos> childs=buildTree(list,id);
                if(childs!=null&&childs.size()>0){
                    sysPos.setChilds(childs);
                }
                r.add(sysPos);//岗位管理树形数据
            }
        }
        return r;
    }
    public  static List<RepairType> repairTree(Collection<RepairType> list, String pid){
        List<RepairType> r=new ArrayList<>();
        for(RepairType repairType:list){
            if(pid.equals(repairType.getPid())){
                String repLabel = repairType.getRepLabel();
                List<RepairType> childs=repairTree(list,repLabel);
                if(childs!=null&&childs.size()>0){
                    repairType.setChilds(childs);
                }
                r.add(repairType);//树形数据
            }
        }
        return r;
    }
}
